package com.wjk.kylin.core.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by brian on 2017/5/29.
 */
@WebFilter(urlPatterns = {"/*"}, filterName = "responseWrapperFilter")
public class ResponseWrapperFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

        //包装response什么都不干
        WrappedHttpServletResponse responseWrapper = new WrappedHttpServletResponse((HttpServletResponse) response);

        //filter链往下走
        chain.doFilter(request, responseWrapper);
    }

    @Override
    public void destroy() {

    }
}
